require "Common/define"
require "Logic/CtrlManager"
require "Logic/Config"
require "Net/roleListHandler"
require "Net/Innatehandler"
require "proto/title/message/ReqSaveShowTitleMessage"
require "proto/title/message/ReqSendShowTitleMessage"
require "proto/title/message/ReqSendTitleInfoMessage"
require "proto/title/message/ResSendActiveTitleMessage"
require "proto/title/message/ResSendShowTitleMessage"
require "proto/title/message/ResSendTitleInfoMessage"
require "model/RoleAttributeModel"
require "model/MercenAttributeModel"

TitleHandler = TitleHandler or {};
G.serverData = G.serverData or {};

--返回当前激活的称号信息
function TitleHandler.ResSendActiveTitle(msg)
    logicMgr.TitleManager.GetTitleRefresh(msg);
    FireEvent(Config.EventType.ActiveTitle, msg);
    TitleHandler.SendTitleInfo();
    --logicMgr.HeroManager.RefreshBadgeAtt()
end

--返回展示的称号列表
function TitleHandler.ResSendShowTitle(msg)
    FireEvent(Config.EventType.ShowTitle, msg);
end

--返回已激活的称号列表
function TitleHandler.ResSendTitleInfo(msg)
    if not logicMgr.TitleManager.SetTitleShowInfo(msg) then
        FireEvent(Config.EventType.TitleInfo, msg);
        logicMgr.HeroManager.RefreshBadgeAtt()

        partnerHandler.ReqHeroPower(0)
    end
end

--请求展示指定玩家的称号列表,0返回玩家自己
function TitleHandler.SendShowTitle(msg)
    local rdtr = ReqSendShowTitleMessage.New();
    rdtr.playerId = msg or 0;
    sendReqMessage(rdtr);
end

--请求已激活的称号列表
function TitleHandler.SendTitleInfo(msg)
    local rdtr = ReqSendTitleInfoMessage.New();
    sendReqMessage(rdtr);
end

--请求保存自身的展示称号列表
function TitleHandler.SaveShowTitle(msg, data)
    local rdtr = ReqSaveShowTitleMessage.New();
    rdtr.titleList = data;
    sendReqMessage(rdtr);

end

